-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transform end-to-end tests into acceptance tests using Behat with in-memory repos #7209
Conversation
class: Pim\Test\Common\Persistence\InMemoryAttributeRepository | ||
|
||
pim_catalog.repository.attribute: | ||
alias: pim_catalog.saver.attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it looks weird but I didn't find another way to use the same instance for two different services :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks ok to me
class: Pim\Test\Common\Persistence\InMemoryAttributeRepository | ||
|
||
pim_catalog.repository.attribute: | ||
alias: pim_catalog.saver.attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks ok to me
@@ -22,6 +22,9 @@ | |||
"classmap": [ "app/AppKernel.php", "app/AppCache.php", "tests/AppKernelTest.php" ] | |||
}, | |||
"autoload-dev": { | |||
"psr-4": { | |||
"Pim\\Test\\": "tests/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if that was meant only for behat, you could move it in the autoload
part of behat.yml (not really important I think)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be used by something else than Behat imho.
@@ -0,0 +1,27 @@ | |||
imports: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't see how you decide which kernel environment to use (I guess in your behat.yml ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right ! I forgot to push the Behat conf. Here it is : https://github.com/akeneo/pim-community-dev/pull/7209/files#diff-7bde54db60a6e933518d8b61b929edceR121
This POC is a follow-up to #7157.
The idea is the same : find a way to transform end-to-end tests into other more relevant and efficient types of tests.
The first POC was very naive and pragmatic, this time I wanted to go further and try to use Behat with Symfony integration to be able to use the DI.
About the tests themselves
I chose validation scenarii as a simple (but not so much at the end) work base.
The old tests were end-to-end, they used :
The goal was to find a way to focus on the business logic.
First step : rework the Gherkin to remove all notions of UI components and call directly business services from the new Behat context. The UI behavior can still be tested by other end-to-end tests.
About how I reworded the tests : I discussed a lot with @jjanvier and @Delphineray about the fact that it should be possible to validate a value collection without using a product (technically we're really close to be able to do it). Indeed, a value collection could be seen as a standalone entity and can be contained by something else, a product model for instance. So it could make sense even from a functional point of view.
Anyway we didn't find any good solution, it looks like it's still not a well defined concept, or at least we couldn't find a common (technical/functional) way to talk about it.
So for the moment i chose to mention products in the Gherkin, it can change later.
Technical solution
Then, to avoid calling the database I used an in-memory repository when needed (for these use cases only the attribute repository was called).
To do that, I needed :
I also created a brand new Behat context. Still not sure about the naming, the files organisation, the steps design, the stateful behavior, how to split it later... Feel free to propose ideas and vision.
Possible next steps
Try it
Launch
bin/behat --profile=acceptance --suite=acceptance
on your machine.